<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>新增其他收入与支出</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="新增,其他,收入,与,支出">
	<meta http-equiv="description" content="This is my page">
	
	<script src='${CONTEXT_PATH}/dwr/interface/incomeExpenseService.js'></script>
	<script src='${CONTEXT_PATH}/dwr/engine.js'></script>
	<script src='${CONTEXT_PATH}/dwr/util.js'></script>
	
	<style type="text/css">
	</style>
	
  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="incomeExpenseCollect" namespace="/inner/charge">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'新增${ie.year}-${ie.month}其他收入与支出'}]"/>
    			<jsp:param name="width" value="70%"/>
    		</jsp:include>
    		
    		<s:hidden name="kindergartenId" id="kindergartenId"></s:hidden>
    		<s:hidden name="ie.year" id="thisYear"></s:hidden>
    		<s:hidden name="ie.month" id="thisMonth"></s:hidden>
    		
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr bgcolor="#FFFFFF">
    				<td align="right" width="20%" class="label">
    					类型：
    				</td>
    				<td align="left" width="30%">
    					<s:select onchange="typeChange()" list="indexTypeList" name="indexType" id="indexType" listKey="id" listValue="dataValue" headerKey="" headerValue="--请选择--" cssStyle="width:90%"></s:select>
    				</td>
    				<td align="right" width="20%" class="label">
    					指标：
    				</td>
    				<td align="left" width="30%">
    					<select name="ie.incomeExpenseIndex.id" id="incomeExpenseIndexId" style="width:95%">
    						<option value="">--请选择--</option>
    					</select>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					时间：
    				</td>
    				<td align="left">
    					<s:textfield name="ie.chargeTime" id="chargeTime" cssStyle="width:95%" cssClass="WDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"></s:textfield>
    				</td>
    				<td align="right" class="label">
    					金额(￥)：
    					<br>
    					<font color="red">(10字以内)</font>
    				</td>
    				<td align="left">
    					<s:textfield name="ie.amount" id="amount" cssStyle="width:95%" maxlength="10"></s:textfield>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					备注：
    					<br>
    					<font color="red">(200字以内)</font>
    				</td>
    				<td align="left" colspan="3">
    					<s:textarea name="ie.remark" id="remark" cssStyle="width:95%; height:160px;"></s:textarea>
    				</td>
    			</tr>
    		</table>
    		
    		<table width="100%" cellspacing="0">
    			<tr>
    				<td align="center" valign="bottom" height="30">
    					<input type="button" value="新增" class="btn" onclick="addIncomeExpense()" />
    				</td>
    			</tr>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function addIncomeExpense()
    {
    	var thisYear = $('#thisYear');
    	var thisMonth = $('#thisMonth');
    	var indexType = $('#indexType');
    	var incomeExpenseIndexId = $('#incomeExpenseIndexId');
    	var chargeTime = $('#chargeTime');
    	var amount = $('#amount');
    	var remark = $('#remark');
    	if(!isNotNull(indexType.val()))
    	{
    		showMsg('类型不能为空。', function(){indexType.focus();});
    		return;
    	}
    	if(!isNotNull(incomeExpenseIndexId.val()))
    	{
    		showMsg('指标不能为空。', function(){incomeExpenseIndexId.focus();});
    		return;
    	}
    	if(!isNotNull(chargeTime.val()))
    	{
    		showMsg('时间不能为空。', function(){chargeTime.focus();});
    		return;
    	}
    	if(!isNotNull(amount.val()))
    	{
    		showMsg('金额不能为空。', function(){amount.focus();});
    		return;
    	}
    	if((isNotNull(amount.val()) && checkFloat(amount) == false) || parseFloat(amount.val(), 10) <= 0)
    	{
    		showMsg('金额有误。', function(){amount.focus();});
    		return;
    	}
    	if(remark.val().length > 200)
    	{
    		showMsg('备注不能超过200字。', function(){remark.focus();});
    		return;
    	}
    	var time = chargeTime.val().split('-');
    	if(thisYear.val() != time[0] || thisMonth.val() != time[1])
    	{
    		showMsg('日期必须为' + thisYear.val() + '-' + thisMonth.val() + '。', function(){chargeTime.focus();});
    		return;
    	}
    	ajaxAction('inner/charge/addIncomeExpense.action', 'post', 'frm', false, function(){
   			if(window.opener != null)
   			{
    			window.opener.searchThis();
    			window.close();
   			}
    	});
    }
    
    function typeChange()
    {
    	var indexType = $('#indexType');
    	if(isNotNull(indexType.val()))
    	{
    		incomeExpenseService.queryIncomeExpenseIndexList(indexType.val(), function(data){
    			addSelectOption('incomeExpenseIndexId', data, 'id', 'indexName', true);
    		});
    	}
    	else
    	{
    		addSelectOption('incomeExpenseIndexId', null, 'id', 'indexName', true);
    	}
    }
    </script>
  </body>
</html>
